**Project: Strategic Discrimination**
**by Regina Bateson**
**Last modified: 21 June 2020**

//This do-file provides the output for the Study 3 results//

//First, the do-file cleans and re-organizes the dataset.//
//Then, the "Analysis 1" section provides the main results in the manuscript.//
//Last, the "Analysis 2" section provides supplemental analysis cited in the manuscript and the appendix.//

**GET THE DATASET**

//Download and save the file Study3.dta //
//It is part of this replication package // 

use "/Users/gina/Dropbox (Personal)/Strategic Discrimination resubmit/Perspectives Final Submission/Data and Replication Files/Study3.dta"

//Of course your version of the dataset is saved differently. Go open it.//

**CLEAN THE DATA AND SET UP VARIABLES**

**drop all subjects who did not pass the screening questions to participate in the experiment**
drop if treatment==""

**1. Create comparison groups**
//This is necessary to be able to compare the treatment groups with the control groups//
gen undercompare=. 
replace underc=1 if treatment=="Underwoodtreatment"
replace underc=0 if treatment=="Conclusion"

gen shamingcompare=.
replace shamingcompare=1 if treatment=="Namingandshamingtreatment"
replace shamingcompare=0 if treatment=="Conclusion"

gen correctcompare=.
replace correctcompare=1 if treatment=="Correctinformationtreatment"
replace correctcompare=0 if treatment=="Conclusion"

gen blackcompare=.
replace blackcompare=1 if treatment=="Blackvotersargument"
replace blackcompare=0 if treatment=="Conclusion"

**2. Create DVs **

replace warren=0 if warren==.
replace harris=0 if harris==.
replace buttigieg=0 if buttigieg==.
replace booker=0 if booker==.
replace klobuchar=0 if klobuchar==.
replace biden=0 if biden==.
replace sanders=0 if sanders==.
replace orourke=0 if orourke==.

//Top choice is a woman (binary)//
gen bestwoman1=0
replace bestwoman1=1 if warren==1
replace bestwoman1=1 if harris==1
replace bestwoman1=1 if klobuchar==1

//Total number of women in the top 3//
gen bestwarrentop3=0
replace bestwarrentop3=1 if warren>0
gen bestharristop3=0
replace bestharristop3=1 if harris>0
gen bestklobuchartop3=0
replace bestklobuchartop3=1 if klobuchar>0
gen bestwomantotal=bestwarrentop3+bestharristop3+bestklobuchartop3

//Are any women in the top 3?//

gen bestwomanbinary=0
replace bestwomanbinary=1 if klobuchar>0
replace bestwomanbinary=1 if warren>0
replace bestwomanbinary=1 if harris>0

//BLACK candidate DVs//

replace booker=0 if booker==.

**Black candidate is top choice (binary)**
gen bestblack1=0
replace bestblack1=1 if harris==1
replace bestblack1=1 if booker==1

**Black candidates is in top 3**
gen bestbookertop3=0
replace bestbookertop3=1 if booker>0
gen bestblacktotal=bestbookertop3+bestharristop3

**Are there any black candidates in the top 3?**
gen bestblackbinary=0
replace bestblackbinary=1 if harris>0
replace bestblackbinary=1 if booker>0

**Make binary variables recording whether each candidate is in the #1 position**
gen biden1=0
replace biden1=1 if biden==1
gen sanders1=0
replace sanders1=1 if sanders==1
gen warren1=0
replace warren1=1 if warren==1
gen harris1=0
replace harris1=1 if harris==1
gen booker1=0
replace booker1=1 if booker==1
gen klobuchar1=0
replace klobuchar1=1 if klobuchar==1
gen buttigieg1=0
replace buttigieg1=1 if buttigieg==1
gen orourke1=0
replace orourke1=1 if orourke==1

**Create binary variables recording whether each candidate is in the top3**

rename bestharristop3 harristop3
rename bestwarrentop3 warrentop3
rename bestbookertop3 bookertop3
rename bestklobuchartop3 klobuchartop3
gen bidentop3=0
replace bidentop3=1 if biden>0
gen sanderstop3=0
replace sanderstop3=1 if sanders>0
gen buttigiegtop3=0
replace buttigiegtop3=1 if buttigieg>0
gen orourketop3=0
replace orourketop3=1 if orourke>0

//Code Subject Demographics//
gen male=0 if gender!="Male"
replace male=1 if gender=="Male"

gen female=0 if gender!="Female"
replace female=1 if gender=="Female"

gen white=0 
replace white=1 if race=="White / Caucasian" 

gen black=0
replace black=1 if race=="Black or African American"

gen api=0
replace api=1 if race=="Asian / Pacific Islander"

gen hispanic=0
replace hispanic=1 if race=="Hispanic or Latino"

gen other=0
replace other=1 if hispanic==0 & api==0 & black==0 & white==0

gen agegroup=1 if age=="18 - 24 years old"
replace agegroup=2 if age=="25 - 34 years old"
replace agegroup=3 if age=="35 - 44 years old"
replace agegroup=4 if age=="45 - 54 years old"
replace agegroup=5 if age=="55 - 64 years old"
replace agegroup=6 if age=="65 - 74 years old"
replace agegroup=7 if age=="75 years or older"

********************************************************************************
*********ANALYSIS 1*************************************************************
********************************************************************************

//For Table 3.2//
**Correct info treatment**

ttest bestblackbin, by(correctc) welch
ttest bestblacktot, by(correctc) welch
ttest bestblack1, by(correctc) welch

ttest bestwomanbin, by(correctc) welch
ttest bestwomantot, by(correctc) welch
ttest bestwoman1, by(correctc) welch

//For Table 3.3//
**Naming and Shaming Treatment**

ttest bestblackbin, by(shamingc) welch
ttest bestblacktot, by(shamingc) welch
ttest bestblack1, by(shamingc) welch

ttest bestwomanbin, by(shamingc) welch
ttest bestwomantot, by(shamingc) welch
ttest bestwoman1, by(shamingc) welch

//For Table 3.4//
**Role Model Treatment**

ttest bestblackbin, by(underc) welch
ttest bestblacktot, by(underc) welch
ttest bestblack1, by(underc) welch

ttest bestwomanbin, by(underc) welch
ttest bestwomantot, by(underc) welch
ttest bestwoman1, by(underc) welch

//For Table 3.5//
**Black Voters Treatment**

ttest bestblacktot, by(blackcomp) welch
ttest bestblackbin, by(blackcomp) welch
ttest bestblack1, by(blackcomp) welch

ttest bestwomantot, by(blackcomp) welch
ttest bestwomanbin, by(blackcomp) welch
ttest bestwoman1, by(blackcomp) welch

********************************************************************************
*********ANALYSIS 2*************************************************************
********************************************************************************

//APPENDIX TABLE 1.35//
**Subject Demographics**

tab agegr
tab female
tab male
tab other
tab white
tab black
tab hispanic
tab api

//The manuscript also includes some discussion of candidate-specific results from Study 3.//
//That disucssion is based on the candidate-specific results below.//

reg warrentop3 blackc
estimates store warren1
reg harristop3 blackc
estimates store harris1
reg klobuchartop3 blackc
estimates store klobuchar1
reg bidentop3 blackc
estimates store biden1
reg sanderstop3 blackc
estimates store sanders1
reg buttigiegtop3 blackc
estimates store buttigieg1
reg orourketop3 blackc
estimates store orourke1
reg bookertop3 blackc
estimates store booker1
coefplot warren1 harris1 klobuchar1 biden1 sanders1 buttigieg1 orourke1 booker1, drop(_cons) xline(0)

reg warrentop3 underc
estimates store warren2
reg harristop3 underc
estimates store harris2
reg klobuchartop3 underc
estimates store klobuchar2
reg bidentop3 underc
estimates store biden2
reg sanderstop3 underc
estimates store sanders2
reg buttigiegtop3 underc
estimates store buttigieg2
reg orourketop3 underc
estimates store orourke2
reg bookertop3 underc
estimates store booker2
coefplot warren2 harris2 klobuchar2 biden2 sanders2 buttigieg2 orourke2 booker2, drop(_cons) xline(0)

reg warrentop3 correctc
estimates store warren3
reg harristop3 correctc
estimates store harris3
reg klobuchartop3 correctc
estimates store klobuchar3
reg bidentop3 correctc
estimates store biden3
reg sanderstop3 correctc
estimates store sanders3
reg buttigiegtop3 correctc
estimates store buttigieg3
reg orourketop3 correctc
estimates store orourke3
reg bookertop3 correctc
estimates store booker3
coefplot warren3 harris3 klobuchar3 biden3 sanders3 buttigieg3 orourke3 booker3, drop(_cons) xline(0)

reg warrentop3 shamingc
estimates store warren4
reg harristop3 shamingc
estimates store harris4
reg klobuchartop3 shamingc
estimates store klobuchar4
reg bidentop3 shamingc
estimates store biden4
reg sanderstop3 shamingc
estimates store sanders4
reg buttigiegtop3 shamingc
estimates store buttigieg4
reg orourketop3 shamingc
estimates store orourke4
reg bookertop3 shamingc
estimates store booker4
coefplot warren4 harris4 klobuchar4 biden4 sanders4 buttigieg4 orourke4 booker4, drop(_cons) xline(0)


reg warren1 blackc
estimates store warren7
reg harris1 blackc
estimates store harris7
reg klobuchar1 blackc
estimates store klobuchar7
reg biden1 blackc
estimates store biden7
reg sanders1 blackc
estimates store sanders7
reg buttigieg1 blackc
estimates store buttigieg7
reg orourke1 blackc
estimates store orourke7
reg booker1 blackc
estimates store booker7
coefplot warren7 harris7 klobuchar7 biden7 sanders7 buttigieg7 orourke7 booker7, drop(_cons) xline(0)

reg warren1 underc
estimates store warren8
reg harris1 underc
estimates store harris8
reg klobuchar1 underc
estimates store klobuchar8
reg biden1 underc
estimates store biden8
reg sanders1 underc
estimates store sanders8
reg buttigieg1 underc
estimates store buttigieg8
reg orourke1 underc
estimates store orourke8
reg booker1 underc
estimates store booker8
coefplot warren8 harris8 klobuchar8 biden8 sanders8 buttigieg8 orourke8 booker8, drop(_cons) xline(0)

reg warren1 correctc
estimates store warren9
reg harris1 correctc
estimates store harris9
reg klobuchar1 correctc
estimates store klobuchar9
reg biden1 correctc
estimates store biden9
reg sanders1 correctc
estimates store sanders9
reg buttigieg1 correctc
estimates store buttigieg9
reg orourke1 correctc
estimates store orourke9
reg booker1 correctc
estimates store booker9
coefplot warren9 harris9 klobuchar9 biden9 sanders9 buttigieg9 orourke9 booker9, drop(_cons) xline(0)

reg warren1 shamingc
estimates store warren11
reg harris1 shamingc
estimates store harris11
reg klobuchar1 shamingc
estimates store klobuchar11
reg biden1 shamingc
estimates store biden11
reg sanders1 shamingc
estimates store sanders11
reg buttigieg1 shamingc
estimates store buttigieg11
reg orourke1 shamingc
estimates store orourke11
reg booker1 shamingc
estimates store booker11
coefplot warren11 harris11 klobuchar11 biden11 sanders11 buttigieg11 orourke11 booker11, drop(_cons) xline(0)

clear 

//Congratulations! You have reached the end of the do-file for Study 3.//

//Any questions? Please consult the Read.Me file for this replication package or email gina.bateson@gmail.com .//


